﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MoveIt.Object.Lines;

namespace MoveIt.Framework
{
    public enum StatusLine
    {
        First = 0,
        Body = 1,
        Last = 2,
    }
    
    public enum IDObject
    {
        BALL,
        HARDLINE,
    }

    /// <summary>
    /// Có các trạng thái chung và riêng của các đối tượng trong game.
    /// </summary>
    public enum IDStatus
    {
        HARD,
    }

    public class CObject
    {
        protected IDObject m_IDObject;
        protected CSprite m_Sprite;
        protected Vector2 m_Position;
        protected Vector2 m_StartPosition; 
        protected IDStatus m_Status;

        protected bool m_IsAlive;
        protected bool m_IsVisible;
        protected bool m_IsColliable; // có khả năng va chạm
        protected Rectangle m_rangMovement;

        protected StatusLine m_StatusLine;

        public StatusLine StatusLine
        {
            get { return m_StatusLine; }
            set { m_StatusLine = value; }
        }

        IDDir m_Direction;

        public IDDir Direction
        {
            get { return m_Direction; }
            set { m_Direction = value; }
        }

        #region. Get & Set Propertiese

        public IDObject IDObject
        {
            get { return m_IDObject; }
            set { m_IDObject = value; }
        }

        public Rectangle Rectangle
        {
            get { return new Rectangle((int)m_Position.X, (int)m_Position.Y, m_Sprite.FrameWidht, m_Sprite.FrameHeight); }
        }

        public CSprite Sprite
        {
            get { return m_Sprite; }
            set { m_Sprite = value; }
        }

        public Vector2 Position
        {
            get { return m_Position; }
            set { m_Position = value; }
        }

        public Vector2 StartPosition
        {
            get { return m_StartPosition; }
            set { m_StartPosition = value; }
        }

        public IDStatus Status
        {
            get { return m_Status; }
            set { m_Status = value; }
        }

        public bool IsAlive
        {
            get { return m_IsAlive; }
            set { m_IsVisible = value; }
        }

        public bool IsVisible
        {
            get { return m_IsVisible; }
            set { m_IsVisible = value; }
        }

        public bool IsColliable
        {
            get { return m_IsColliable; }
            set { m_IsColliable = value; }
        }

        #endregion

        public CObject(Vector2 _Position)
        {
            m_Position = _Position;
            m_StartPosition = m_Position;
            m_Sprite = null;
            //m_Status = IDStatus.ALIVE;
            m_IsAlive = true;
            m_IsVisible = false;
            m_IsColliable = false;
            m_rangMovement = new Rectangle((int)m_Position.X - 200,(int) m_Position.Y - 200, 200, 200);
        }

        public CObject(IDObject _IDObject, Vector2 _Position)
        {
            m_IDObject = _IDObject;
            m_Position = _Position;
            m_StartPosition = m_Position;
            m_Sprite = null;
            //m_Status = IDStatus.ALIVE;
            m_IsAlive = true;
            m_IsVisible = false;
            m_IsColliable = true;
        }

        virtual public void Init()
        { 

        }

        virtual public void SetItem(CAnimationObject _Item)
        {

        }

        virtual public void UpdateAnimation(GameTime _GameTime, CInput _Input)
        {
            _Input.Update();
            m_Sprite.UpdateAnimation(_GameTime);
        }

        virtual public void UpdateMovement(GameTime _GameTime, CInput _Input)
        {

        }

        virtual public void UpdateCollision(CAnimationObject _Object)
        {

        }

        virtual public void Draw(SpriteBatch _SpriteBatch)
        {
            m_Sprite.Position = m_Position;
            m_Sprite.Draw(_SpriteBatch);
        }
    }
}
